﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.flagship
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int fid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(fid);
				}
			}
		}
			
	private void ShowInfo(int fid)
	{
		jnxc.BLL.flagship bll=new jnxc.BLL.flagship();
		jnxc.Model.flagship model=bll.GetModel(fid);
		this.lblfid.Text=model.fid.ToString();
		this.txtfname.Text=model.fname;
		this.txtflinker.Text=model.flinker;
		this.txtfphone.Text=model.fphone;
		this.txtftel.Text=model.ftel;
		this.txtfbrief.Text=model.fbrief;
		this.txtfpic.Text=model.fpic;
		this.txtfadd.Text=model.fadd;
		this.txtfprovince.Text=model.fprovince;
		this.txtfcity.Text=model.fcity;
		this.txtfcounty.Text=model.fcounty;
		this.txtuid.Text=model.uid.ToString();
		this.txtftime.Text=model.ftime.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtfname.Text.Trim().Length==0)
			{
				strErr+="店名不能为空！\\n";	
			}
			if(this.txtflinker.Text.Trim().Length==0)
			{
				strErr+="联系人不能为空！\\n";	
			}
			if(this.txtfphone.Text.Trim().Length==0)
			{
				strErr+="手机不能为空！\\n";	
			}
			if(this.txtftel.Text.Trim().Length==0)
			{
				strErr+="电话不能为空！\\n";	
			}
			if(this.txtfbrief.Text.Trim().Length==0)
			{
				strErr+="简介不能为空！\\n";	
			}
			if(this.txtfpic.Text.Trim().Length==0)
			{
				strErr+="图片不能为空！\\n";	
			}
			if(this.txtfadd.Text.Trim().Length==0)
			{
				strErr+="地址不能为空！\\n";	
			}
			if(this.txtfprovince.Text.Trim().Length==0)
			{
				strErr+="省不能为空！\\n";	
			}
			if(this.txtfcity.Text.Trim().Length==0)
			{
				strErr+="市不能为空！\\n";	
			}
			if(this.txtfcounty.Text.Trim().Length==0)
			{
				strErr+="县不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtuid.Text))
			{
				strErr+="所有人格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtftime.Text))
			{
				strErr+="开店时间格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int fid=int.Parse(this.lblfid.Text);
			string fname=this.txtfname.Text;
			string flinker=this.txtflinker.Text;
			string fphone=this.txtfphone.Text;
			string ftel=this.txtftel.Text;
			string fbrief=this.txtfbrief.Text;
			string fpic=this.txtfpic.Text;
			string fadd=this.txtfadd.Text;
			string fprovince=this.txtfprovince.Text;
			string fcity=this.txtfcity.Text;
			string fcounty=this.txtfcounty.Text;
			int uid=int.Parse(this.txtuid.Text);
			DateTime ftime=DateTime.Parse(this.txtftime.Text);


			jnxc.Model.flagship model=new jnxc.Model.flagship();
			model.fid=fid;
			model.fname=fname;
			model.flinker=flinker;
			model.fphone=fphone;
			model.ftel=ftel;
			model.fbrief=fbrief;
			model.fpic=fpic;
			model.fadd=fadd;
			model.fprovince=fprovince;
			model.fcity=fcity;
			model.fcounty=fcounty;
			model.uid=uid;
			model.ftime=ftime;

			jnxc.BLL.flagship bll=new jnxc.BLL.flagship();
			bll.Update(model);
			jnxc.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
